<template>
		<div class="">
			<div class="slideNav" refs="slideNav" :class="{slideDown:slideDown}">
					<router-link to="/" class="tab"><p>首页</p></router-link>
					<router-link :class="{active:item.tid==getCurTid}" v-for="(item,index) in navList" :key="item.tid" :to="{name:'channel',params:{tid:item.tid}}" v-if="item.typename.split('').length<=2" class="tab"><p>{{item.typename}}</p></router-link>
					<router-link :class="{active:item.tid==getCurTid}" v-else :to="{name:'channel',params:{tid:item.tid}}" class="otab"><p>{{item.typename}}</p></router-link>
					<a v-for="(item,index) in 4" :key="index*100"  class="tab keng"><p>占坑</p></a>
					<div class="shangla" @click="slideNav">
						<svg class="icon_shangla">
							<use xlink:href="#icon-shouqixiao"></use>
						</svg>
					</div>
				</div>
				
				<div class="scrollContainer">
					<div class="scrollWrap" ref="scrollWrap" >
						<router-link to="/" class="tab"><p>首页</p></router-link>
						<router-link v-for="(item,index) in navList" :class="{active:item.tid==getCurTid}" :key="item.tid*100" :to="{name:'channel',params:{tid:item.tid}}" class="tab"><p>{{item.typename}}</p></router-link>
					</div>
					<div class="xiala" @click="slideNav">
						<svg class="icon_xiala">
							<use xlink:href="#icon-xialaxiao"></use>
						</svg>
					</div>
				</div>
		</div>
</template>

<script>
	export default {
		data(){
			return {
				navList:[],
				slideDown:false
			}
		},
		created(){
			this.navList=window.__INITIAL_STATE__.reduxAsyncConnect.partitionList[0]
			this.$store.commit("setCurTid",{
				curTid:this.$route.params.tid 
			})
		},
		mounted(){
			
		},
		methods:{
			slideNav(){
				this.slideDown=!this.slideDown
			}
		},
		computed:{
			getCurTid(){
//				拿到对应的键名
				return this.$store.getters.getCurTid
			},
			
		}
		
	}
</script>

<style lang="scss" type="text/css">
	@import "~@/common/scss/common";
	.scrollContainer{
		position: fixed;
		top:64px;
		width: 100%;
		height: 30px;
		overflow-x: scroll;
		white-space: nowrap;
		overflow:hidden;
		text-align: center;
		z-index: 2;
		background-color: #fff;
	}	
		
	.tab{
		display: inline-block;
		width: 30px;
		font-size: 14px;
		color: $fontcolor;
		margin-right: 20px;
	}
		.slideNav{
			position: fixed;
			z-index: 3;
			width: 100%;
			transition: transform .4s linear;	
			transform: translateY(-200px);
			display: flex;
			justify-content: space-between;
			align-items: center;
			flex-wrap: wrap;
			background: #fff;
			.active p{
				color: $maincolor;
    			border-bottom: 2px solid $maincolor;
			}
			a{
				
				width: 15%;
				text-align: center;
				font-size: 15px;
				margin: 0;
				padding: 10px 3px;
				box-sizing: border-box;
				p{
					display: inline-block;
					color: $fontcolor;
					border-bottom: 2px solid transparent;
				}
			}
			.router-link-exact-active{
				p{
					border-bottom: 2px solid $maincolor;
				}
			}
			.otab{
				display: inline-block;
				font-size: 14px;
				color: $fontcolor;
				padding: 10px 0px;
			}
			.keng{
				p{
					color: #fff;
					display: inline-block;
					border-bottom: 2px solid #fff;
				}
			}
			.shangla{
				position: relative;
				width: 100%;
				svg{
					display: block;
					width: 20px;
					height: 20px;
					margin: auto;
					fill: #aaa;
				}
			}
		}
		.slideDown{
				transform: translateY(-32px);
			}
	.scrollWrap{
		position: relative;
		width: 88%;
		height:30px;
		padding-left: 16px;
		padding-bottom:6px;
		overflow-x: scroll;
		-webkit-overflow-scrolling:touch;
		&::-webkit-scrollbar{
			display: none;
		}
		.router-link-exact-active,.active{
			color:$maincolor;
			border-bottom: 2px solid $maincolor;
		}
	}
	
	.xiala{
		position: absolute;
		right:0;
		top:0;
		width: 8%;
		.icon_xiala{
			display: block;
			width: 20px;
			height: 20px;
			fill: #aaa;
			margin: auto;
		}
	}
</style>